<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- react底层核心库 -->
    <script src="https://unpkg.com/react@17/umd/react.development.js"></script>
    <!-- react操作DOM的核心库，类似于jquery -->
    <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
    <!-- 用于解析babel -->
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
</head>

<body>
    <div id='root1'></div>
    <script type="text/babel">
        let flag = false
        let login = <div><h1>登录</h1></div>
        let logout = <div><h1>登出</h1></div>
        ReactDOM.render(
            flag ? login : logout,
            document.getElementById('root1')
        )

    </script>

    <div id="root2"></div>
    <script type="text/babel">
        //函数式组件
        function App() {
            let flag = false
            let login = <div><h1>登录</h1></div>
            let logout = <div><h1>登出</h1></div>
            return flag?login:logout
        }

        ReactDOM.render(<App />,document.getElementById('root2'))
    </script>
</body>

</html>